package com.abvnet.project.water.project.controller;

import com.abvnet.framework.aspectj.lang.annotation.Log;
import com.abvnet.framework.aspectj.lang.enums.BusinessType;
import com.abvnet.framework.web.controller.BaseController;
import com.abvnet.framework.web.domain.AjaxResult;
import com.abvnet.project.water.project.domain.ProjectWater;
import com.abvnet.project.water.project.service.IProjectWaterService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/project/projectWater")
public class ProjectWaterController extends BaseController {

    private String prefix = "project/projectInfo";

    @Autowired
    private IProjectWaterService projectWaterService;

    @GetMapping("/edit/{projectId}")
    public String edit(@PathVariable("projectId") Long projectId, ModelMap mmap) {
        mmap.put("projectWater", projectWaterService.selectProjectWaterByProjectId(projectId));
        return prefix + "/water";
    }

    @Log(title = "水质指标情况", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ProjectWater projectWater) {
        return toAjax(projectWaterService.updateProjectWater(projectWater));
    }
}
